<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .liclass {
            color: blue;
        }
    </style>
</head>

<body>
    <div class="vueDiv">
        <ul>
            <!-- 思路：设置一个状态码变量 当状态码=下标的时候 换色 -->
            <li :class="{liclass:currentIndex == index}" v-for="(item,index) in items" :key="item" @click='changeCurrentIndex(index)'>
                {{item}}
            </li>
        </ul>
    </div>
    <script src="../vue.js"></script>
    <script>
        const vue01 = new Vue({
            el: '.vueDiv',
            data: {
                items: ['aaa', 'bbb', 'ddd', 'ccc'],
                currentIndex: 0,
            },
            methods: {
                changeCurrentIndex(index) {
                    console.log('method do')
                    this.currentIndex = index;
                    
                }
            },
        })
    </script>
</body>

</html>